BUILD_FLAGS := -std=c99 -O0 -pipe -funsigned-char
WARNING_FLAGS := -Wall -Wextra -Wconversion -Wtraditional-conversion -Werror -pedantic-errors

BUILD_DIR := ../build
OBJECTS := $(patsubst %.c, $(BUILD_DIR)/%.o, $(wildcard *.c))
CXX := gcc -c $(BUILD_FLAGS) $(WARNING_FLAGS) -o $(BUILD_DIR)/
OUTPUT_BIN := $(BUILD_DIR)/btree

build: $(OBJECTS)
	gcc -o $(OUTPUT_BIN) $(OBJECTS)

$(BUILD_DIR)/test.o: test.c
	$(CXX)test.o test.c

$(BUILD_DIR)/btdata.o: btdata.c btdata.h
	$(CXX)btdata.o btdata.c

$(BUILD_DIR)/btree.o: btree.c btree.h
	$(CXX)btree.o btree.c

.PHONY: clean
clean:
	rm -f $(OBJECTS)
